<template>
    <div>
        <component :is="view" v-on="events" v-bind="props" ></component>
        <a-button @click="loadView">loadView</a-button>
    </div>
</template>
<script>
import component1 from "./component1.vue";
import AppUtil from "../../../assets/js/AppUtil";
export default {
    name: "dynamicComponent",
    components: {
        "component1":component1
    },
    data() {
        return {
            view: "component1",
            //定义事件
            events: {
                submit: (val) => {
                    console.log(val);
                }
            }
        }
    },
    methods:{
        loadView(){
            //动态加载组件
            let component = AppUtil.loadComponent('modules/demo/component2.vue') ;
            this.view=component;
        }
    }
}
</script>

